﻿using System;
using HumanResources;

namespace ConsoleApplication1
{
    class Program
    {
        int instancevariable;
        delegate float somemethod();

        public static void NoisyWatcher(string prop, object data)
        {
            Console.WriteLine("A property, {0} changed to {1}",
                prop, data);
        }

        static void Main(string[] args)
        {
            try
            {
                somemethod thefunc;

                EventLogger paylogger = new EventLogger(@"c:\development\paystuff.txt");
                EventLogger propertylogger = new EventLogger(@"c:\development\propchanges.txt");
                EventLogger alllogger = new EventLogger(@"c:\development\all.txt");

                Employee emp;
                emp = new Employee("Chuck", "000-00-0000", 100);
                emp.PayEvent += paylogger.logEvent;
                emp.PropertyChangeEvent += propertylogger.logEvent;
                emp.PayEvent += Program.NoisyWatcher;


                emp.Pay();

                emp.Pay(20.5f);

                emp.Name = "Chuck";
                emp.TaxId = "123-45-6789";

                TaxEntity t;

                Type ttype = Type.GetType("HumanResources.Employee");


                Employee mary = new Employee("Mary", "123-45-6789", 101);

                mary.SocialSecurityNumber = "000-00-0000";
                thefunc = emp.Pay;

                thefunc();  // caling pay  - emp is on the left side of the dot

                Company teex = new Company("TEEX", "01-5554444");
                teex.PayEvent += Program.NoisyWatcher;
                teex.PayEvent += paylogger.logEvent;

                teex.Hire(emp);
                teex.Hire(mary);

                float netpay = teex.Pay();
                Console.WriteLine("Just paid {0} to my employees.  {1} ytd pay is {2}",
                    netpay, emp.Name, emp.YtdSalary);

                PayrollClerk pc = new PayrollClerk();
                Piper thepiper = new Piper();
                thepiper.Pay();
                pc.PayThese(emp, mary, teex, thepiper);
                pc.PayThese(thepiper);

                float net = emp.Pay();
                Console.WriteLine(net);
                net = emp + 500;
                Console.WriteLine("just paid {0} with + operator", net);

                Console.WriteLine("{0} has a salary of {1:c}, ytd taxes {2:c} ", emp.Name, emp.Salary, emp.YtdTax);

                Console.ReadLine();
            }
            catch (ValidationException e)
            {
                Console.Write(e);
            }
        }


    }
}
